﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.ComponentModel.DataAnnotations;
using System.Data.Entity.ModelConfiguration;

namespace Business.Models
{
    public class TinNhan
    {
        [Key]
        public int IdTinNhan { get; set; }
        //public int IdHocSinh { get; set; }
        public virtual HocSinh HocSinh { get; set; }
        public string NoiDung { get; set; }
        public DateTime ThoiGianQueue { get; set; }
        public DateTime ThoiGianGui { get; set; }
        public byte TrangThai { get; set; }
        //public int NguoiGui { get; set; }
        public virtual NhanVien NhanVien { get; set; }
    }
    public class TinNhanConfiguration : EntityTypeConfiguration<TinNhan>
    {

        public TinNhanConfiguration()
            : base()
        {

            HasKey(d => d.IdTinNhan);
            Property(d => d.IdTinNhan).
                HasColumnName("IdTinNhan").
                HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity).
                IsRequired();
            HasRequired(x => x.HocSinh).
            WithMany().
                Map(x => x.MapKey("IdHocSinh"));
            Property(d => d.NoiDung).
                HasColumnName("NoiDung").
                IsRequired();
            Property(d => d.ThoiGianQueue).
                HasColumnName("ThoiGianQueue").
                IsRequired();
            Property(d => d.ThoiGianGui).
                HasColumnName("ThoiGianGui").
                IsRequired();
            Property(d => d.TrangThai).
                HasColumnName("TrangThai").
                IsRequired();
            HasRequired(x => x.NhanVien).
            WithMany().
                Map(x => x.MapKey("NguoiGui"));
            ToTable("TinNhan", "dbo");
        }

    }
}